// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once
#include <opencv2/opencv.hpp>
#include <paddle_api.h>
#include <paddle_inference_api.h>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <ostream>
#include <vector>

#include <cstring>
#include <fstream>
#include <numeric>

#include "pdmodel_manager.h"

struct LogInfo;

namespace paddle_infer {

class ResizeImgType0;
class Normalize;
class Permute;
class OCRPostProcessor;

class OCRDetector {
public:
  OCRDetector(LogInfo *log_info);

  int Run(cv::Mat& img, 
              std::vector<BaseInfoPD*> &text_lines, 
              PDModelManager *mng,
              int model_idx );

private:

  int RunDB(cv::Mat& img, 
              std::vector<BaseInfoPD*> &text_lines, 
              PDModelManager *mng,
              int model_idx );

private:

  std::vector<float> mean_ = {0.485f, 0.456f, 0.406f};
  std::vector<float> scale_ = {1 / 0.229f, 1 / 0.224f, 1 / 0.225f};
  bool is_scale_ = true;
  // pre-process
  // ResizeImgType0 *resize_op_;
  // Normalize0 *normalize_op_;
  // Permute *permute_op_;

  // post-process
  OCRPostProcessor *post_processor_;
  LogInfo *log_ifo;

};

} // namespace paddle_infer

